package com.mcarthur.countdown.client.drawable;

import com.googlecode.gwtgl.binding.WebGLRenderingContext;

public class BouncyBall extends Ball {
	
	private float velX;
	private float velY;
	private Vector2 center;

	public BouncyBall() {
		super(0.f, null);
		center = new Vector2();
	    calculateCenter();
	}

	public void setVelX(float velX) {
		this.velX = velX;
	}

	public float getVelX() {
		return velX;
	}

	public void setVelY(float velY) {
		this.velY = velY;
	}

	public float getVelY() {
		return velY;
	}
	
	@Override
	public void draw(WebGLRenderingContext gl) {
	    gl.vertexAttrib3f(Ball.colorLoc, activeColor.r, activeColor.g, activeColor.b);
		super.draw(gl);
	}
	
	// The following is needed for collision calculations
	
	public Vector2 getCenter() {
		return center;
	}
	
	@Override
	public void setPosX(float posX) {
		super.setPosX(posX);
		calculateCenter();
	}
	
	@Override
	public void setPosY(float posY) {
		super.setPosY(posY);
		calculateCenter();
	}
	
	private void calculateCenter() {
		center.x = posX + Ball.RADIUS;
		center.y = posY + Ball.RADIUS;
	}
}
